package org.lida.converter.config;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.StringHttpMessageConverter;

import java.nio.charset.Charset;

/**
 * author: lida
 * create time: 2020-09-01 11:16
 * description: 方法一：自定义了一个消息转换器
 */
//@SpringBootConfiguration
public class AppConfig {

    @Bean
    public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
        FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
        //给这个JSON格式设置个编码
        converter.setDefaultCharset(Charset.forName("UTF-8"));
        return converter;
    }

    @Bean
    public StringHttpMessageConverter stringHttpMessageConverter() {
        return new StringHttpMessageConverter(Charset.forName("ISO-8859-1"));
    }
}
